<style scoped src="./index.scss" lang="scss" rel="stylesheet/scss"></style>
<template src="./index.html"></template>
<script>
export default {
  data() {
    return {
      username: "",
      password: "",
      loading: false,
    };
  },

  components: {},
  methods: {
    async submit() {
      if (!this.username || !this.password) {
        this.$vFN.Tools.messageError("请填写完整的账号和密码");
        return;
      }

      this.loading = true;

      // 获取token
      let _data = await this.$vFN.Http.post(
        {
          isToken: false,
          isLoading: false,
          url: "mall-admin/sys-login/login",
          data: {
            username: this.username,
            password: this.password,
          },
        },
        window
      );

      if (_data._ok) {
        this.$vFN.Tools.setToken({
          expiresIn: _data.data.expiresIn,
          token: _data.data.token,
          tokenHead: _data.data.tokenHead,
        });
        // this.$vFN.Tools.messageSuccess("登录成功")

        this.$router.push({
          path: "/admin/home",
        });
      }

      this.loading = false;
    },
  },

  computed: {},
  mounted() {},
  activated() {},
};
</script>